﻿using LuckyShell.ShellOrders;
using LuckyShell.ShellValues;

namespace LuckyShell.Commands;

public class HelpCommand(List<ShellValue> values) : Command(values)
{
    public override object Run(ref VariateManager manager)
    {
        switch (Values.Count)
        {
            case 0:
                Console.WriteLine(Api.Help);
                break;
            case 1:
            {
                var value = Values[0].GetValue(ref manager);
                if (value is not string valueString) throw new Exception("Value is Not String");
                //Console.WriteLine(Api.Test(valueString));
                switch (valueString)
                {
                    case "codeArg":
                        foreach (var s in Api.TestString)
                            Console.Write($"{s} ");
                        Console.WriteLine();
                        break;
                }

                break;
            }
            case 2:
            {
                var value = Values[0].GetValue(ref manager);
                var value2 = Values[1].GetValue(ref manager);
                if (value2 is not string valueString2 || value is not string valueString)
                    throw new Exception("Value is Not String");
                switch (valueString)
                {
                    case "code":
                        Console.WriteLine(Api.Test(valueString2));
                        break;
                }

                break;
            }
        }

        return new VoidValue();
    }
}